﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Entity.ModelConfiguration;
using INSE6260.OnlineBanking.Model.Transaction;

namespace INSE6260.OnlineBanking.Repository.EF.Mappings
{
    class TransactionConfiguration: EntityTypeConfiguration<Transaction>
    {
        public TransactionConfiguration()
        {					
    		this.HasKey(t => t.Id);		
    		this.ToTable("Transaction");
    		this.Property(t => t.Id).HasColumnName("Id");
    		this.Property(t => t.TransactionDate).HasColumnName("TransactionDate");
    		this.Property(t => t.Amount).HasColumnName("Amount");
    		this.Property(t => t.TransactionType).HasColumnName("TransactionType").IsRequired().IsUnicode(false).HasMaxLength(20);
    		this.Property(t => t.FromAccountId).HasColumnName("FromAccountId");
    		this.Property(t => t.ToAccountId).HasColumnName("ToAccountId");
    		this.Property(t => t.Balance).HasColumnName("Balance");
    		this.HasRequired(t => t.Account).WithMany(t => t.Transactions).HasForeignKey(d => d.FromAccountId);
    		this.HasRequired(t => t.Account1).WithMany(t => t.Transactions1).HasForeignKey(d => d.ToAccountId);
    	}
    }
}